package com.damagez.selfrefresh.redis;

import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

import java.lang.reflect.Method;

/**
 * @author damage
 * @create 2020/5/12 9:48
 * @description
 */
public class RefreshRedisCacheKeyGenerator implements KeyGenerator {

    public static final String BEAN_NAME = "refreshRedisCacheKeyGenerator";

    public static final String SEPARATOR = "_";

    @Override
    public Object generate(Object target, Method method, Object... params) {
        return ClassUtils.getUserClass(target).getName() + SEPARATOR
                + method.getName() + SEPARATOR
                + StringUtils.arrayToDelimitedString(params, SEPARATOR);
    }
}
